import { Ref, ref } from 'vue'
import { deepClone } from '../utils'
/**
 * 生成一个可以重置的ref
 * @param data 
 */
export function useResetRef<T>(data:T): [Ref, () => void] {
    const initValue =deepClone(data)
    const state = ref<T | typeof data>(data)
    const reset = () => {
        state.value = deepClone(initValue)
    }
    return [state, reset]
}